﻿using System.Collections.Generic;
using System.Text;

namespace Sustainalytics.DynamicsCRMGateway
{
    public class SchemaValidationResult
    {
        public List<EntityValidationResult> Entities { get; set; }
        
        public bool IsValid { get; set; }

        public string ErrorMessage {get;set;}

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("IsValid = " + IsValid);
            if (Entities != null)
            {
                foreach (var entity in Entities)
                {
                    sb.Append(string.Format("\n {0}", entity ));
                }
            }

            return sb.ToString();
        }
    }

    public class EntityValidationResult
    {
        public List<string> Errors { get; set; }

        public string EntityName { get; set; }

        public bool IsValid { get; set; }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(string.Format("[{0}] IsValid = {1} ", EntityName, IsValid));
            if (Errors != null)
            {
                sb.Append(", Errors:{");
                foreach (var error in Errors)
                {
                    sb.Append(string.Format("\n {0}", error));
                }
                sb.Append("}");
            }

            return sb.ToString();
        }
    }
}
